import 'package:flutter/material.dart';
import 'package:flutter_getx/GetXControllerWorkersExample/WorkersController.dart';
import 'package:get/get.dart';

class GetXControllerWorkersExample extends StatelessWidget {
  GetXControllerWorkersExample({super.key});

  final WorkersController workersController = Get.put(WorkersController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("GetXControllerWorkers"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Obx(
              () => Text("count 值为 ${workersController.count.value}"),
            ),
            ElevatedButton(
              onPressed: () {
                workersController.increment();
              },
              child: const Text("增加"),
            ),
            Padding(
              padding: const EdgeInsets.all(16),
              child: TextField(
                onChanged: (val) {
                  workersController.increment();
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}
